<?php

/**
 * Description of Groupement
 *
 * @author ROCU Fabien
 */
class Groupement {

    private $groupement_id;

    public $groupement_nom;

	function __construct( )
	{

	}

    public function select_groupement( $id )
    {
        global $_mysql;

		try
		{
			$query = "SELECT groupement_nom FROM groupement WHERE groupement_id = $id;";
			$result = $_mysql->query($query);

			if ($_mysql->num_rows($result) > 0)
			{
				$val = $_mysql->fetch_array($result);

                $this->groupement_nom = $val['groupement_nom'];

			}
			else
				throw new Exception('Erreur SELECT Groupement');

		}
		catch (SQLException $sqle)
		{
			throw $sqle;
		}
    }

    public function insert_groupement( $nom )
    {
        global $_mysql;

		try
		{
			$query = "INSERT INTO groupement VALUES ( null, '$nom' );";
			$result = $_mysql->query($query);

			if ($result) { }
			else
				throw new Exception('Erreur INSERT Groupement');

		}
		catch (SQLException $sqle)
		{
			throw $sqle;
		}
    }

    public function delete_groupement ( $id )
    {
        global $_mysql;

		try
		{
			$query = "DELETE FROM groupement WHERE groupement_id = $id";
			$result = $_mysql->query($query);

			if ($result) { }
			else
				throw new SQLException('Erreur DELETE Groupement');

		}
		catch (SQLException $sqle)
		{
			throw $sqle;
		}
    }

}

?>
